function serializeDecorator(target: any, propertyKey: any): any {
  const key = propertyKey;
  // 重写属性的get方法
  const getter = function () {
    return localStorage.getItem(key);
  };

  // 重写属性的set方法
  const setter = function (newValue: any) {
    localStorage.setItem(key, newValue);
  };

  // 使用Object.defineProperty来重写属性的行为
  Object.defineProperty(target, propertyKey, {
    get: getter,
    set: setter,
    enumerable: true,
    configurable: true,
  });

  // 返回修改后的属性描述符
  return {
    get: getter,
    set: setter,
  };
}

class StorageDataClass {
  @serializeDecorator
  chxLoginRegion = '';
  @serializeDecorator
  lastRegion = '';
  @serializeDecorator
  chxMergeSelect: any = ''; // 选项列表
  @serializeDecorator
  chxMergeDistrict = ''; // 省市区列表
  @serializeDecorator
  adminPermissions = ''; // 权限列表
  @serializeDecorator
  chxMergeRegion = ''; // 当前登录的地区id
  @serializeDecorator
  region_cdn_id = ''; // 当前登录的地区id 新版
  @serializeDecorator
  chxMergetoken = ''; // 当前登录的token
  @serializeDecorator
  xcMenuMap = ''; //菜单id
  @serializeDecorator
  chxMergeDepartment = '';
  @serializeDecorator
  chxMergeAllDepartment = '';
  @serializeDecorator
  adminInfo = '';
  @serializeDecorator
  is_join_supplier = '';
  @serializeDecorator
  join_supplier = '';
}

export const StorageData = new StorageDataClass();
